libxl: ao: Provide manip_refcnt
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 20 Dec 2013 16:34:41 +0000 (16:34 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Fri, 26 Jun 2015 15:53:50 +0000 (16:53 +0100)
commitbc0b4c80cb61583eba2fd99a21d6a4e337233818
tree72d545fce143f302e14cba594f18bc81d0a88207
parentb1102ae7b4d19b8df78d5c9b48305cc3787488aa
libxl: ao: Provide manip_refcnt

Previously we used in_initiator to stop the ao being freed while we
were still in the initiator function (which would result in the
initiator's call to libxl__ao_inprogress accessing the ao after it had
been freed).

We are going to introduce a new libxl entrypoint which finds, and
operates on, ongoing aos.  This function needs the same protection,
and might even end up running on the same ao multiple times
concurrently.

So do this with reference counting instead, with a new variable
ao->manip_refcnt.

We keep ao->in_initiator because that allows us to keep some useful
asserts about the sequencing of libxl__ao_inprogress, etc.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
---
v5: Fix typo in commit message.
v3: Add a missing space.
    Mention locking in the comment.
tools/libxl/libxl_event.c
tools/libxl/libxl_internal.h